﻿using UnityEngine;
using System.Collections;
using UnityEngine.UI;


public class TestAlphaFade : MonoBehaviour
{
    public Image image;
    public Material _material;

    private float xfadeValue = 0.0f;
    private float yfadevalue = 0.0f;
    public float delayTime = 0f;

    private void Awake()
    {
        image = this.GetComponent<Image>();
        _material = image.material;
    }

    // Use this for initialization
    void Start()
    {
        StartCoroutine("ChangeAlpha");
    }

    IEnumerator ChangeAlpha()
    {
        while (delayTime<5f)
        {
            delayTime += Time.fixedDeltaTime;
            yield return new WaitForEndOfFrame();
            _material.SetVector("_Gradient", new Vector3(delayTime, delayTime,0.1f));
        }

    }
}
